<?php
// +----------------------------------------------------------------------
// | HkCms 插件
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------

namespace app\addons\controller;

use think\Controller;

class Error extends Controller {

    //插件标识
    public $addonName = NULL;
    //插件路径
    protected $addonPath = NULL;

    public function init() {
        $this->addonName = request()->controller();
        $this->addonPath = model('addons/Addons')->getAddonsPath() . strtolower($this->addonName) . '/';
    }

    public function _empty()
    {
        $this->init();
        $isAdmin = input('isadmin');
        $class = $isAdmin ? 'Admin' : 'Index';

        define('ADDON_MODULE_NAME', strtolower($class));
        $className = "\\addon\\".strtolower($this->addonName)."\\controller\\{$class}";
        $object = new $className;
        $method = request()->action();
        return $object->$method();
    }
}
